;;; package.cfg.el --- Summary
;;; Commentary:
;;; package configuration.
;;; Code:

;;;###autoload
(defun package-install-if-absent (package &optional repository)
  "Install PACKAGE if it has not yet been installed.
If REPOSITORY is specified, use that.
This function tries to be conservative.  It will try to install
PACKAGE from the local archive first.  In case of failure, it will
contact the repository over the network and retry."
  (unless (package-installed-p package)
    (let ((package-archives (if repository
                                (list (assoc repository package-archives))
                              package-archives)))
      (condition-case nil
          (package-install package)
        (error (progn
                 (package-refresh-contents)
                 (condition-case nil
                     (package-install package)
                   (error (message (format "Could not install %s after refreshing contents" package))))))))))

(require 'package)
(package-initialize)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives
             '("melpa-stable" . "http://stable.melpa.org/packages/"))
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))

(package-install-if-absent 'use-package)
(eval-when-compile
  (require 'use-package))

;; Ensure correct indentation for use-package.
(put 'use-package 'lisp-indent-function 1)

(package-install-if-absent 'diminish)
(require 'diminish) ;; to use :diminish
(require 'bind-key) ;; to use :bind

(provide 'package.cfg)
;;; package.cfg.el ends here
